package com.xzzz.irda.guardcat.server.setting;

import com.xzzz.common.base.pojo.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 【Server】警告配置
 */
@Slf4j
@RestController
@RequestMapping("/guardcat/server/alert")
public class GuardcatSettingController {

    @Autowired
    public AlertSettingManager settingManager;

    /**
     * 应用的警告配置
     *
     * @param appName 应用名称
     * @return 警告配置
     */
    @GetMapping("/setting")
    public R<AlertSetting> setting(String appName) {
        return R.ok(settingManager.get(appName));
    }

    /**
     * 保存警告配置
     *
     * @param setting 机器ID
     */
    @PostMapping("/setting")
    public R<Boolean> setting(@RequestBody AlertSetting setting) {
        return R.ok(settingManager.save(setting));
    }

}
